<div id='{$form.name}' name='{$form.name}'>

<div style="padding-left:0px;padding-right:0px;">
<table></table>
<div style="width:640px; height:400px;" id="map_contianer">

	<div id="map_canvas" style="width:100%; height:100%;"  ></div>
	{literal}
 </div>	
</div>

	<script>
		
		
		setTimeout(function(){

		{/literal}
		{if $dataPanel.data|count >0}
		 {foreach item=row name=locations from=$dataPanel.data}
		 	{if $smarty.foreach.locations.first}
		  	var myLatlng = new google.maps.LatLng({$row.fld_latitude},{$row.fld_longtitude});
			var defaultZoom=13;		 	
			{/if}
		 {/foreach}
		 {else}
			var myLatlng = new google.maps.LatLng({$smarty.const.DEFAULT_LATITUDE},{$smarty.const.DEFAULT_LONGTITUDE});
			var defaultZoom=10;
		 {/if}
		{literal}
		var myOptions = {
	      zoom: defaultZoom,
		  center: myLatlng,		  	      
	      mapTypeId: google.maps.MapTypeId.ROADMAP
	     }
		
		var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
	    {/literal}
	    {foreach item=row name=locations from=$dataPanel.data}
		{literal} 
			var myLatlng_{/literal}{$row.fld_Id}{literal} = new google.maps.LatLng({/literal}{$row.fld_latitude}{literal},{/literal}{$row.fld_longtitude}{literal});
		    var infowindow_{/literal}{$row.fld_Id}{literal} = new google.maps.InfoWindow({
		        content:'{/literal}{$row.fld_description|addslashes}{literal}'						
		    });
	
		    var marker_{/literal}{$row.fld_Id}{literal} = new google.maps.Marker({
		        position: myLatlng_{/literal}{$row.fld_Id}{literal},
		        map: map,
				draggable: true,
		        title: '{/literal}{$row.fld_title|addslashes}{literal}'
		    });		
		    google.maps.event.addListener(marker_{/literal}{$row.fld_Id}{literal}, 'click', function() {		    	
				Openbiz.CallFunction('{/literal}{$form.name}{literal}.SwitchForm(location.widget.LocationDetailForm,{/literal}{$row.fld_Id}{literal},,Dialog)',{'type':'','target':'','evthdl':'btn_add:fld_add_onclick'});				 								
		    });
			
			google.maps.event.addListener(marker_{/literal}{$row.fld_Id}{literal}, 'dragend', function(event) {					    	    	
				Openbiz.CallFunction('{/literal}{$form.name}{literal}.UpdateLocation({/literal}{$row.fld_Id}{literal},'+event.latLng.lat()+','+event.latLng.lng()+')',{'type':'','target':'','evthdl':'btn_add:fld_add_onclick'});				
		    });
			
			//infowindow_{/literal}{$row.fld_Id}{literal}.open(map,marker_{/literal}{$row.fld_Id}{literal});
		{/literal}
		{/foreach}	
		 {literal}
	    google.maps.event.addListener(map, 'click', function(event) {
	    	var paramFields='';
			
			paramFields += 'longtitude='+event.latLng.lng()+'&';
			paramFields += 'latitude='+event.latLng.lat()+'&';
			Openbiz.CallFunction('{/literal}{$form.name}{literal}.SwitchForm(location.widget.LocationNewForm,,'+paramFields+',Dialog)',{'type':'','target':'','evthdl':'btn_add:fld_add_onclick'});
	    });
		
					
			
		},100);
	</script>
	{/literal}
</div>